/******************************************************************************
 *      Mestrado em Ciência da Computação - UFMS
 *		Redes de Computadores - Prof. Dr. Ronaldo Alves Ferreira
 *		Alunos: Geraldo Landre, Marcel Tolentino, Vinícius Bueno
 *****************************************************************************/

#ifndef DEFINES_H
#define	DEFINES_H

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <semaphore.h>
#include <ctype.h>
#include "../httpd/base.h"

//
// Constants
//

#ifndef NULL
#define NULL 0
#endif

#define	min(a,b)	( (a) < (b) ? (a) : (b) )
#define	max(a,b)	( (a) > (b) ? (a) : (b) )

#define NTCP 256 // escolhido por ser base2 e pequena

#define OK      1
#define SYSERR -1


#define	TCP         19
#define	LOWBYTE		0377		/* mask for low-order 8 bits	*/
#define	HIBYTE		0177400		/* mask for high 8 of 16 bits	*/

#define TIMERGRAN        1		// timer granularity, secs/10

#define	RTF_REMOTE	0	/* traffic is from a remote host	*/
#define	RTF_LOCAL	1	/* traffic is locally generated		*/

#define	TCPSBS          4096    /* TCP send buffer sizes	*/
#define	TCPRBS          8192	/* TCP receive buffer sizes	*/

#define	IP_MINHLEN	5	/* minimum IP header length (in longs)	*/
#define	IP_MAXLEN	BPMAXB-EP_HLEN	/* Maximum IP datagram length	*/
#define	IP_ALEN         4		/* IP address length in bytes (octets)	*/
#define	IPT_TCP		6	/* protocol type for TCP packets	*/
#define	BPMAXB          8192			/* max buffer size for mkpool	*/
#define	EP_HLEN		24	/* size of (extended) Ether header	*/
#define	ANYPORT         0	/* accept any foreign UDP port	*/
//
// Basic types
//

typedef unsigned long   u_long;
typedef	unsigned long   ipaddr;	/*  internet address			*/
typedef unsigned short  u_short;
typedef unsigned char   u_char;
typedef unsigned char   bool;
#define false   0;
#define true    1;

//
// Structures
//

//
// Global Variables
//
unsigned    TcpInSegs,  // TcpInSegs
            TcpInErrs,  // TcpInErrs
            TcpOutSegs, // TcpOutSegs
            TcpOutRsts, //
            TcpPassiveOpens,
            TcpEstabResets,
            TcpCurrEstab,
            TcpActiveOpens,
            TcpRetransSegs,
            TcpAttemptFails,
            TcpCurrEstab;

int dnparse(char *fspec, ipaddr *paddr, unsigned short *pport);
ipaddr dot2ip(const char *pdot);

#endif	/* DEFINES_H */

